home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Fax Class1&ARA&Data < prev    next >
Text File  |  1995-03-13  |  8KB  |  450 lines

  1. ! Version 3.0.2
  2. !
  3. !$ Use this script with Class 1 fax software working in the "numeric answers"
  4. !$ mode (FaxSTF,Faxilitate), ARA 1.0 or 2.0,
  5. !$ and a BBS, E-mail or other communication server software
  6. !
  7. !$ This script allows to place fax AND ARA/data calls, and it allows to receive
  8. !$ fax OR ARA/data calls.
  9. !
  10. !$ A cable for hardware handshaking is required
  11.  
  12. ^# Modem:
  13. ^2 Fax Software:     = Enum("FaxSTFェ"="0","Faxilitate"="1") "0"
  14. ^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
  15. ^4 Incoming Calls:   = Enum("Fax"="0","ARA/Data"="1") "1"
  16. ^5 Data Port Speed:  = Enum("9600","19200","38400") "19200"
  17. ! ------------------------------------------
  18. ! Resetting the modem:
  19. ! ------------------------------------------
  20. @Hangup
  21.   SetTries 2
  22.   Flush
  23.   HsReset 0,0,17,19,0,0
  24.   DtrSet
  25. !
  26. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  27. ! to enter the command mode
  28. !
  29. @Label 1
  30.   matchclr
  31.   matchstr 1 2 "OK¥r¥n"
  32.   write "ATH0V1Q0¥r"
  33.   matchread 20
  34.   ChrDelay 1
  35.   Write "+++"
  36.   ChrDelay 0
  37.   SBreak
  38.   DtrClear
  39.   Pause 5
  40.   DtrSet
  41.   Pause 5
  42. !
  43.   DecTries
  44.   IfTries 0 1
  45. !
  46. ! OSErr -6019 "Modem error - the modem is not responding"
  47. !
  48.   exit -6019
  49. @Label 2
  50.   SetVar A "&F"
  51.   GetOption A "DFLT" 3
  52. @Label 3
  53.   write "AT^A+FCLASS=0¥r"
  54.   Jsr 100
  55.   exit 0
  56.  
  57. @Label 6
  58.   Say "This script cannot be used with this modem"
  59.   ifOriginate 9
  60.   pause 1800
  61. @Label 9
  62.   exit -6019
  63.  
  64. ! ------------------------------------------
  65. !    Receiving incoming calls
  66. ! ------------------------------------------
  67. @ANSWER
  68. !
  69. ! Set the modem preferred speed first
  70.   SerReset 19200,0,8,1
  71.   Jsr 80
  72.  
  73. @Label 10
  74. !
  75. ! Set the common options
  76.   Jsr 70
  77.  
  78. !
  79. ! Go to Fax receive if required
  80. !
  81.   ifStr 4 40 "0"
  82. !
  83. ! ARA/Data call waiting
  84. !
  85. !
  86. ! Set the desired speed
  87.   SerReset Val("^5"),0,8,1
  88.   Jsr 80
  89. !
  90. ! Set the data options
  91.   Jsr 75
  92.  
  93.   GetCommand B "Data" "M"
  94.   GetCommand C "Data" "L"
  95.   GetCommand D "Data" "S0"
  96.   SetVar A "S0=3"
  97.   ifStr D 16 "S0=0"
  98.   ifStr D 16 ""
  99.   SetVar A "^D"
  100. @Label 16
  101. !
  102. ! Set the speaker and S0
  103.   Write "AT^A^B^C¥r"
  104.   Jsr 100
  105. !
  106. ! Everything is ready - let's sit and wait for a data call
  107. ! We'll wait for 2 minutes, then reinitiate the modem
  108. !
  109.   Note "Waiting for an ARA/DATA callノ"
  110.   Jsr 90
  111.   IfStr C 10 "NONE"
  112.  
  113.   IfOpen "Data" 21
  114.   Jump 30
  115. @Label 21
  116.   IfOpen "ARA" 22
  117.   Jump 35
  118. @Label 22
  119.   Note "Waiting for an ARA frame"
  120.   MatchClr
  121.   MatchStr 1 23 "^$¥r"
  122.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  123.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  124.   MatchRead 40
  125.   Jump 24
  126. @Label 23
  127.   QueueInput "^$¥r"
  128. @Label 24
  129.   Note "Non-ARA call"
  130.   Jump 35
  131.  
  132. @Label 28
  133.   Note "ARA 1.0 call"
  134.   Jump 30
  135. @Label 29
  136.   Note "ARA 2.0 call"
  137.   Jump 30
  138.  
  139. @Label 30
  140.   QueueInput "¥r¥nCARRIER ^B¥r¥n"  
  141.   IfStr A 31 "NONE"
  142.   IfStr A 31 "None"
  143.   QueueInput "¥r¥nREL¥r¥n"
  144. @Label 31
  145.   IfOriginate 32
  146.   QueueInput "¥r¥nRING¥r¥n"
  147. @Label 32
  148.   Attach "ARA" (DTR)
  149.  
  150. @Label 35
  151.   GetSReg C "DATA" 4
  152.   QueueInput "¥r^CCONNECT ^B¥r^C"
  153.   ifOriginate 36
  154.   QueueInput "¥r^CRING¥r^C"
  155. @Label 36
  156.   HsReset 0,1,17,19,0,1
  157.   Attach "Data" (DTR,Escape,Break)
  158.  
  159. !
  160. ! Receiving Fax calls
  161. !
  162. @Label 40
  163.   Write "AT+FCLASS=1¥r"
  164.   Jsr 100
  165. !
  166. ! Get the Speaker and the Ring Num options
  167.   GetCommand B "Fax" "M"
  168.   GetCommand C "Fax" "L"
  169.   GetCommand D "Fax" "S0"
  170.   SetVar A "S0=7"
  171.   ifStr D 41 "S0=0"
  172.   ifStr D 41 ""
  173.   SetVar A "^D"
  174. @Label 41
  175. !
  176. ! Set the speaker and S0, switch to the numeric mode.
  177.   Write "AT^A^B^CV0¥r"
  178.   Jsr 110
  179. !
  180. ! Everything is ready - let's sit and wait for a fax call
  181. ! We'll wait for 2 minutes, then reinitiate the modem
  182.   Note "Waiting for a fax callノ"
  183.   Jsr 85
  184.   IfStr C 49 "NONE"
  185. !
  186. ! Fax connection has been established (we read "CONNECT")
  187. ! Put the CONNECT ("1¥r") back to the buffer,
  188. ! if it was an incoming call, put the "RING" before it
  189. @Label 45
  190.   QueueInput "1¥r"
  191.   ifOriginate 47
  192. @Label 46
  193.   QueueInput "2¥r2¥r"
  194. @Label 47
  195.   Attach "Fax" (DTR,Reset(2400),IdleLimit=30)
  196.  
  197. @Label 49
  198.   Write "ATV1¥r"
  199.   Jsr 100
  200.   Jump 40
  201. ! ------------------------------------------
  202. ! Originating a call through the "ARA" subport
  203. ! ------------------------------------------
  204. @ORIGINATE "ARA"
  205.   SerReset Val("^5"),0,8,1
  206.   Jsr 80
  207. !
  208. ! Set the common options
  209.   Jsr 70
  210. !
  211. ! Set the communication options:
  212.   Jsr 75
  213. !
  214. ! Emit the ARA script commands ("Xnn")
  215.   Jsr 60
  216. !
  217. ! dial the number
  218.   Write "ATD^1¥r"
  219. !
  220. ! Wait for a modem response
  221.   Jsr 90
  222.   IfStr C 30 "DATA"
  223.   Write "¥r"
  224.   Exit -6019
  225.  
  226. ! ------------------------------------------
  227. ! Originating a call through the "DATA" subport
  228. ! ------------------------------------------
  229. @ORIGINATE "Data" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  230.   SerReset 19200,0,8,1
  231.   Jsr 80
  232. !
  233. ! Set the common options
  234.   Jsr 70
  235. !
  236. ! Set the communication options:
  237.   Jsr 75
  238. !
  239. ! dial the number
  240.   Write "ATD^1¥r"
  241.   HsReset *
  242. !
  243. ! Wait for a modem response
  244.   Jsr 90
  245.   IfStr C 35 "DATA"
  246.   Write "¥r"
  247.   Exit -6019
  248.  
  249. ! ------------------------------------------
  250. ! Originating a call through the "Fax" subPort
  251. ! ------------------------------------------
  252. @ORIGINATE "Fax" ("¥r¥nLineShare Line is Busy¥r¥nBUSY¥r¥n")
  253. !
  254. ! Set the "Fax" speed
  255. !
  256.   SerReset 19200,0,8,1
  257.   Jsr 80
  258. !
  259. ! Set the common options
  260. !
  261.   Jsr 70
  262.   GetOption A "SWHS" 6
  263. !
  264. ! Set the Fax mode (Xon/Xoff)
  265.   Write "AT^A+FCLASS=1¥r"
  266.   Jsr 100
  267. !
  268. ! Now emit all commands that the application has sent to that port,
  269. ! except "+FCLASS", etc
  270. !
  271.   EmitClear "+FCLASS","V","E"
  272.   Jsr 60
  273. !
  274. ! Prepare to receive all error result codes, dial the number
  275. !
  276.   Write "ATV0D^1¥r"
  277.   HsReset *
  278.   Jsr 85
  279.   IfStr C 45 "FAX"
  280.   Write "¥r"
  281.   Exit -6019
  282. !
  283. !
  284. ! This section emits all modem commands sent from the client application
  285. ! For each set of commands the "OK" answer is awaited
  286. !
  287. @Label 60
  288.   EmitStart
  289. @Label 61
  290.   EmitCommand 62
  291.   Jsr 100
  292.   Jump 61
  293. @Label 62
  294.   return
  295. !
  296. ! This section initiates the modem before ANSWER and ORIGINATEs:
  297. ! extended responses + connect at the highest rate + speaker control +
  298. ! reset on Dtr drop + DCD valid
  299. ! Verbal responses mode, no echo 
  300. !
  301. @Label 70
  302.   Write "AT&D2&C1V1E0¥r"
  303.   Jsr 100
  304.   return 
  305.  
  306. ! Set the communication options:
  307. ! ・ Normal/AUTO Connection
  308. ! ・ HW flow control  (for ARA, Fax should not use a handshake on receiving)
  309. ! ・ CONNECT <DCE speed> or CARRIER/CONNECT
  310. @Label 75
  311.   GetOption A "HWHS" 6
  312.   GetOption B "^3" 6
  313.   GetOption C "LNRS" 6
  314.   Write "AT^A^B^C¥r"
  315.   Jump 100
  316.  
  317. !
  318. ! This section syncronize the modem after the serial port speed switching
  319. !
  320. @Label 80
  321.   ChrDelay 1
  322.   Write "AT¥r"
  323.   ChrDelay 0
  324.   Jsr 100
  325.   return
  326. !
  327. ! Error Codes
  328. @Label 81
  329.   exit -6020
  330. @Label 82
  331.   exit -6022
  332. @Label 83
  333.   exit -6021
  334. @Label 84
  335.   exit -6023
  336.  
  337. !
  338. ! Connecting in the numeric mode (fax)
  339. ! On exit:
  340. ! ^C contains "NONE" if no connection has been established
  341. @Label 85
  342.   MatchClr
  343.   MatchStr 1 88 "1¥r"
  344.   MatchStr 2 87 "2¥r"
  345.   MatchStr 5 81 "6¥r"
  346.   MatchStr 6 82 "7¥r"
  347.   MatchStr 7 83 "3¥r"
  348.   MatchStr 8 84 "8¥r"
  349. @Label 86
  350.   Matchread 1200
  351.   SetVar C "NONE"
  352.   return
  353.  
  354. @Label 87
  355.   Note "Ringノ"
  356.   Jump 86
  357. @Label 88
  358.   SetVar C "FAX"
  359.   return
  360.  
  361. !
  362. ! This subroutine waits for the modem response (data mode)
  363. ! On exit:
  364. ! ^A contains the protocol used
  365. ! ^B contains the carrier speed
  366. ! ^C contains "NONE" if no connection has been established
  367. ! If modem reports an error, the scripts exits with an error code
  368. !
  369. @Label 90
  370.   SetVar A "NONE"
  371.   SetVar B ""
  372.   MatchClr
  373.   Matchstr 1 92 "CARRIER ^$¥r¥n"
  374.   Matchstr 2 93 "PROTOCOL: ^$¥r¥n"
  375.  
  376.   Matchstr 4 95 "CONNECT ^$/"
  377.   Matchstr 5 97 "CONNECT ^$¥r¥n"
  378.   Matchstr 6 94 "RING¥r¥n"
  379.   Matchstr 10 82 "BUSY¥r¥n"
  380.   MatchStr 11 83 "NO CARRIER¥r¥n"
  381.   MatchStr 12 84 "NO ANSWER¥r¥n"
  382. @Label 91
  383.   Matchread 1200
  384.   SetVar C "NONE"
  385.   return
  386.  
  387. @Label 92
  388.   SetVar B "^$"
  389.   Jump 91
  390. @Label 93
  391.   SetVar A "^$"
  392.   Jump 91
  393. @Label 94
  394.   Note "Ringノ"
  395.   Jump 91
  396.  
  397.  
  398. ! CONNECT xxxx/XXXX was detected
  399. @Label 95
  400.   Jsr 98
  401.   MatchClr
  402.   MatchStr 1 96 "^$¥r¥n"
  403.   MatchRead 10
  404. @Label 96
  405.   SetVar A "^$"
  406.   SetVar C "DATA"
  407.   return
  408.  
  409. ! CONNECT xxx was detected
  410. @Label 97
  411.   Jsr 98
  412.   SetVar C "DATA"
  413.   return
  414.  
  415. @Label 98
  416.   ifStr B 99 ""
  417.   return
  418. @Label 99
  419.   SetVar B "^$"
  420.   return 
  421.  
  422. !
  423. ! Processing an AT command:
  424. ! OK -> proceed
  425. ! ERROR or TimeOut ->exit -6019
  426. ! It can be called AFTER the "Write" command, since LineShare buffers input
  427. !
  428. @Label 100
  429.   MatchClr
  430.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  431.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  432. @Label 101
  433.   MatchRead 20
  434. @Label 102
  435.   Exit -6019
  436. @Label 103
  437.   return
  438.  
  439. !
  440. ! Processing an AT command in the numeric mode
  441. ! OK -> proceed
  442. ! ERROR or TimeOut ->exit -6019
  443. ! It can be called AFTER the "Write" command, since LineShare buffers input
  444. !
  445. @Label 110
  446.   MatchClr
  447.   MatchStr 1 103 "0¥r"
  448.   MatchStr 2 102 "4¥r"
  449.   Jump 101
  450.